package com.ss.android.newmedia.e;

import com.bytedance.common.utility.Logger;
import com.ss.android.common.load.AsyncLoader.LoaderProxy;
import com.ss.android.newmedia.util.AppUtil;

import java.util.Iterator;

final class b implements LoaderProxy {
    private final AlertManager a;

    b(AlertManager arg1) {
        this.a = arg1;
    }

    private com.ss.android.newmedia.f.a a(com.ss.android.newmedia.f.a arg12) {
        boolean v0_2;
        com.ss.android.newmedia.f.a v0 = null;
        if (arg12 == null) {
            return v0;
        }

        String v2 = arg12.c;
        String v6 = com.bytedance.common.utility.aa.md5(v2);
        boolean v10 = this.a.e.existsInExternalCache(v6);
        if (v10) {
            arg12.e = true;
            return arg12;
        }

        arg12.e = false;
        try {
            v0_2 = AppUtil.downloadImage(this.a.a, -1, v2, (String) null, this.a.e.getExternalImageSaveDir(v6), null, v6, null, null, this.a.f);
        } catch (Throwable v0_1) {
            Logger.d("AlertManager", "download alert image error:" + v0_1);
            v0_2 = v10;
        }

        arg12.e = v0_2;
        return arg12;
    }

    public final Object doInBackground(Object key, Object param, Object extra) {
        return this.a(((com.ss.android.newmedia.f.a) param));
    }

    public final void onLoaded(Object key, Object param, Object extra, Object result) {
        Object v0;
        if (param != null) {
            Iterator v1 = this.a.l.iterator();
            do {
                if (v1.hasNext()) {
                    v0 = v1.next();
                    if (v0 == null) {
                        continue;
                    }

                    if (((com.ss.android.newmedia.f.a) v0).b != ((com.ss.android.newmedia.f.a) result).b) {
                        continue;
                    }

                    break;
                }

                return;
            }
            while (true);

            ((com.ss.android.newmedia.f.a) v0).e = ((com.ss.android.newmedia.f.a) result).e;
        }
    }
}

